/**
 *
 * Copyright 2016-present reading
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
import * as types from '../constants/ActionTypes';

export function requestTeamList(
  token,
  site_id,
  isRefreshing,
  loading,
  isLoadMore,
  page = 1
) {
  return {
    type: types.REQUEST_TEAM_LIST,
    token,
    site_id,
    isRefreshing,
    loading,
    isLoadMore,
    page
  };
}

export function fetchTeamList(isRefreshing, loading, isLoadMore = false) {
  return {
    type: types.FETCH_TEAM_LIST,
    isRefreshing,
    loading,
    isLoadMore
  };
}

export function receiveTeamList(teamList, loading) {
  return {
    type: types.RECEIVE_TEAM_LIST,
    teamList,
    loading
  };
}


export function requestTeamDetail(
  token,
  teamId
) {
  return {
    type: types.REQUEST_TEAM_DETAIL,
    token,
    teamId
  };
}

export function fetchTeamDetail() {
  return {
    type: types.FETCH_TEAM_DETAIL
  };
}

export function receiveTeamDetail(team) {
  return {
    type: types.RECEIVE_TEAM_DETAIL,
    team
  };
}


export function startSaveTeam(loading) {
  return {
    type: types.START_SAVE_TEAM,
    loading: loading
  }
}

export function requestSaveTeam(team, siteId, token) {
  return {
    type: types.REQUEST_SAVE_TEAM,
    team: team,
    token: token,
    siteId: siteId
  }
}

export function responseSaveTeam(team, response, loading) {
  return {
    type: types.RESPONSE_SAVE_TEAM,
    loading: loading,
    response: response,
    team: team
  }
}

export function resetTeamType() {
  return {
    type: types.RESET_TEAM_TYPE,
    saveTeamRes: {}
  }
}

export function emptyTeamList(teamList, loading) {
  return {
    type: types.EMPTY_TEAM_LIST,
    loading: loading,
    teamList: teamList
  }
}
